package com.service.impl;

import com.entity.PageBean;
import com.entity.PurGoods;
import com.entity.PurOrder;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mapper.PurGoodsMapper;
import com.mapper.PurOrderMapper;
import com.service.PurGoodsService;
import com.service.PurOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PurGoodsServiceImpl implements PurGoodsService {
    @Autowired
    private PurGoodsMapper purGoodsMapper;


    @Override
    public PageBean<PurGoods> getGoodsList(Integer pageIndex, Integer pageSize, PurGoods purGoods) {
        PageHelper.startPage(pageIndex, pageSize);
        List<PurGoods> list= purGoodsMapper.selectGoodsList(purGoods);
        PageInfo<PurGoods> pageInfo = new PageInfo<>(list);
        PageBean<PurGoods> pageBean = new PageBean<>(
                pageIndex,//第几页
                pageSize,//每页显示的条数
                pageInfo.getPages(),//总页数
                (int)pageInfo.getTotal(),//数据总条数
                pageInfo.getList()//当前页的数据集合
        );
        return pageBean;
    }

    @Override
    public List<PurGoods> findAll() {
        return purGoodsMapper.findAll();
    }

}
